package lk.icta.core.web.action;

import com.opensymphony.xwork2.ActionSupport;
import lk.icta.common.AppConstants;
import lk.icta.common.dao.GNDivisionDAO;
import lk.icta.common.entity.DSDivision;
import lk.icta.common.web.action.BaseAction;
import lk.icta.core.entity.Land;
import lk.icta.core.entity.Objection;
import lk.icta.core.entity.Schedule;
import lk.icta.core.service.LandManagementService;
import lk.icta.core.service.ObjectionManagementService;
import lk.icta.core.service.ScheduleManagementService;
import org.apache.struts2.interceptor.SessionAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

/**
 * @author Kusal Samarakoon
 */

public class ObjectionAction extends ActionSupport {

    private static final Logger logger = LoggerFactory.getLogger(ObjectionAction.class);

    private final ObjectionManagementService objectionManagementService;

    private long applicationId;
    private Objection objection;

    public ObjectionAction(ObjectionManagementService objectionManagementService) {
        this.objectionManagementService = objectionManagementService;
    }

    public String welcome() {
        logger.debug("Load Objection ");
        return SUCCESS;
    }

    public String pageLoad() {
        logger.debug("Load Objection appId ");
        return SUCCESS;
    }

    public String addObjection() {
        logger.debug("add Objection applicationId {}",applicationId);
        try{
            objection.setApplicationId(applicationId);
            objectionManagementService.addObjection(objection);
            addActionMessage("Objection details saved successfully !");

        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }

        return SUCCESS;
    }

    public long getApplicationId() {
        return applicationId;
    }

    public void setApplicationId(long applicationId) {
        this.applicationId = applicationId;
    }

    public Objection getObjection() {
        return objection;
    }

    public void setObjection(Objection objection) {
        this.objection = objection;
    }
}
